package jwdt.xadmin.work.action;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.system.bean.TUser;
import jwdt.xadmin.work.bean.TWorkLog;
import jwdt.xadmin.work.service.WorkLogManageService;

import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/work")
public class WorkLogManagerAction extends BaseAction {
	
	private WorkLogManageService workLogManageService = (WorkLogManageService)app.getBean("worklogManageService");
	
	@RequestMapping("/listWorkLog")
	public Page doListWorkLog(Form f, Module m) throws Exception {
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TUser userInfo = (TUser) f.getSession("userInfo");
		TWorkLog obj = (TWorkLog)f.copy2Class(TWorkLog.class);
    	return m.getWritePage(f, workLogManageService.doList(pu,obj,userInfo).toJson());
	}
	
	@RequestMapping("/listAllWorkLog")
	public Page doListAllWorkLog(Form f, Module m) throws Exception {
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TUser userInfo = (TUser)f.copy2Class(TUser.class);
		TWorkLog obj = (TWorkLog)f.copy2Class(TWorkLog.class);
    	return m.getWritePage(f, workLogManageService.doList(pu,obj,userInfo).toJson());
	}
	
	@RequestMapping("/addWorkLog")
	public Page doAddact(Form f, Module m) throws Exception {
		TWorkLog obj = (TWorkLog)f.copy2Class(TWorkLog.class);
		TUser userInfo = (TUser) f.getSession("userInfo");
		return m.getWritePage(f, workLogManageService.doAddact(obj,userInfo));
	}
	
	@RequestMapping("/editWorkLog")
	public Page doEditact(Form f, Module m) throws Exception {
		int logid = f.getInt("logid");
		TWorkLog obj = (TWorkLog)f.copy2Class(TWorkLog.class);
		return m.getWritePage(f, workLogManageService.doEditact(obj, logid));
	}
	
	@RequestMapping("/delWorkLog")
	public Page doDel(Form f, Module m) throws Exception {
		int logid = f.getInt("logid");
		return m.getWritePage(f, workLogManageService.doDelact(logid));
	}
	
	@RequestMapping("/workLogWindow")
	public Page doLoad(Form f, Module m) throws Exception {
		int logid = f.getInt("logid");
		f.add("obj", workLogManageService.doLoad(logid));
		return m.findPage("/xadmin/work/workLogWindow");
	}
}
